<?php
declare(strict_types=1);
namespace SixShop\Message\Controller\Admin;

use SixShop\Core\Request;
use SixShop\Message\Entity\MessageNotificationsEntity;
use think\Response;

use function SixShop\Core\page_response;
use function SixShop\Core\success_response;

class MessageController
{
    /**
     * 获取新消息数量
     */
    public function index(Request $request, MessageNotificationsEntity $messageNotificationsEntity)
    {
        $params = $request->get([
            'is_read/d' => 0,
        ]);
        $params['admin_id'] = $request->adminID;
        return page_response($messageNotificationsEntity->getList($params, $request->pageAndLimit()));
    }

    /**
     * 标记消息为已读
     */
    public function read(int $id, MessageNotificationsEntity $messageNotificationsEntity):Response
    {
        return success_response($messageNotificationsEntity->read($id));
    }
}